﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
using Texfina.Core.Common;  
using Texfina.Core.Web;
using Texfina.Common.Mg;
using Texfina.Core.Data;  
using Texfina.Entity.Rh;
using Texfina.Entity.Mg;
using RHBOQry = Texfina.BOQry.Rh;
using MGBOQry = Texfina.BOQry.Mg;

namespace RH
{
   public partial class wfConcepRemu : SearchPage 
   {
       public const int _GRDLIST_IDESTADO = 5;
    
      protected void Page_Load(object sender, EventArgs e)
      {
                       

         this.LoadInitialSettings();
         if(this.IsPostBack){
            this.LoadInPostBack();
            return;
         } 

         this.LoadData();
         SearchData();

      }

      public override void LoadInitialSettings()
      {
         Label lbl = (Label) this.Master.FindControl("lblTitle");
         lbl.Text = "Concepto Remunerativo";
         this.Page.Form.DefaultButton = bttSearch.UniqueID;
      }

      public override void LoadListControls()
      {

          ETablaGenDet objEDet = new ETablaGenDet();
          MGBOQry.ITablaGen objBOI = (MGBOQry.ITablaGen)WCFHelper.GetObject<MGBOQry.ITablaGen>(typeof(MGBOQry.TablaGen));
        
          objEDet.IdTabla = ConstMultitabla.TIPO_CONCEPTO_PLANILLA;
          DataTable dt = objBOI.GetDetailByList(objEDet);
          WebHelper.LoadListControl(ddlidTipConcep, dt, "dsDescrip", "idCodigo", true, true);

      }
      public override void SearchData()
      {

         EConcepRemu objE = new EConcepRemu();

         objE.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();

         if (this.txtidConRemu .Text == "")
            objE.IdConRemu = null;
         else
            objE.IdConRemu = this.txtidConRemu.Text;

         if (this.txtdsConRemu.Text == "")
            objE.DsConRemu  = null;
         else
            objE.DsConRemu = this.txtdsConRemu.Text;

         if (this.ddlidTipConcep.SelectedValue.ToString() == "")
             objE.IdTipConcep = null;
         else
             objE.IdTipConcep = this.ddlidTipConcep.SelectedValue.ToString();

         if (Request.QueryString["StCtaCte"] != null)
            objE.StCtaCte = Request.QueryString["StCtaCte"].ToString();
         else
            objE.StCtaCte = null;


         IBOQuery objBO = (IBOQuery)WCFHelper.GetObject<IBOQuery>(typeof(RHBOQry.ConcepRemu));
         DataTable dt = objBO.GetByCriteria(objE);

         this.GridSetDataBinding(grdList, dt);

      }

      protected void bttOk_Click(object sender, EventArgs e)
      {
          this.SearchData();
      }

      protected void grdList_RowCreated(object sender, GridViewRowEventArgs e)
      {
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
            e.Row.Attributes.Add("ondblclick", "rowDblClick(" + e.Row.RowIndex.ToString() + ")");
         }
      }

   }
}